package com.briup.service.impl;

import com.briup.exception.ServiceException;
import com.briup.response.ResultCode;
import com.briup.service.UploadService;
import com.briup.utils.UploadUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author by ca
 * @date 2024-11-05  16:08
 */
@Service
public class UploadServiceImpl implements UploadService {

    @Autowired
    private UploadUtils uploadUtils;

    @Override
    public String upload(MultipartFile img) {
        String url;
        try {
            url = uploadUtils.fileToOSS(img);
        } catch (Exception e) {
            e.printStackTrace();
            throw new ServiceException(ResultCode.DATA_WRONG);
        }
        return url;
    }
}
